<html xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
    <title>dati</title>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>



    <script src="/js/common.js"></script>
</head>
<body>
<style>
    .navbar{
        background: #d2edf4;
        background-image: linear-gradient(to bottom, #d0edf5, #e1e5f0 100%);
    }
    .container{
        background-color: transparent;
    }
</style>
<div class="container" id="app" >

    <div class="post">
        <table class="table table-hover">
            <tr>
                <td>分类名称</td>
                <td>操作</td>
            </tr>
            <tr v-for="(item, i) in items">
                <td>{{item.typeName}}</td>
                <td>
                    <button type="button" class="btn btn-danger"  v-on:click="deleteType(item.typeID)">删除</button>
                    <button type="button" class="btn btn-success"  v-on:click="editType(item.typeID,item.typeName)">修改</button>
                </td>
            </tr>
        </table>
        <button  class="btn btn-primary  btn-block" onclick="javascript:location.href='/toAddType'">新增</button>

    </div>

</div>
<script>

    var app = new Vue({
        el: '#app',
        data: {
            picked: '',
            freshName:'',
            nextPage:1,
            prePage:1,
            pageSize:4,
            isLastPage:true,
            isFirstPage:true,
            type:'',
            items: [
            ]
        },
        methods: {
            deleteType:function (typeID) {
                var params={
                    typeID:typeID
                };
                $.ajax({
                    type : "post",
                    url : "/user/deleteType",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("删除成功");
                            location.reload();
                        }
                        else {
                            alert("连接错误");
                        }
                    }
                });
            },
            editType:function (typeID,typeName) {
                location.href="toEditType?typeID="+typeID+"&typeName="+typeName;
            }
        }
    });
    $(document).ready(function(){
        var params1={
            pageNum:1,
            pageSize:4,
        }
        $.ajax({
            type : "post",
            url : "/user/showTypeList",
            data : params1,
            success : function(data) {
                app.items=data.typeList;
            }
        });
    })
</script>
</body>
</html>